<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>监听事件</title>
</head>

<body>
    <div id="app">
        <button v-on:click="say('hi')">Say hi</button>
        <button v-on:click="say('what')">Say what</button>

        <button v-on:click="warn('Form cannot be submitted yet.', $event)">
            Submit
        </button>
    </div>

    <script type="module">
        import Vue from '../vue.esm.browser.js'

        const app = new Vue({
            el: '#app',
            data: {},
            methods: {
                say: function (message) {
                    alert(message)
                },
                warn: function (message, event) {
                    // 现在我们可以访问原生事件对象
                    if (event) {
                        event.preventDefault()
                    }
                    alert(message)
                }
            }
        })
    </script>
</body>

</html>